<?php


use Workerman\Worker;
use Workerman\Lib\Timer;
use think\facade\Cache;
use trade\common\gather\GatherAliyun_TfFutures as Gather;
//use trade\common\gather\GatherRandom_TfFutures as Gather;

$worker        = new Worker();
$worker->name  = 'GatherWorker';
$worker->count = 4;
$worker->onWorkerStart = function($worker)
{
	
	sleep($worker->id+1);
    Timer::add(2, function() use ($worker)
    {
        $time = time();
        $stime1 = strtotime(date('Y-m-d ') . ' 09:25:00');
		$etime1 = strtotime(date('Y-m-d ') . ' 11:30:00');
		$stime2 = strtotime(date('Y-m-d ') . ' 13:00:00');
	    $etime2 = strtotime(date('Y-m-d ') . ' 15:01:00');
//	    if ( (($time > $stime1 && $time < $etime1) || ($time > $stime2 && $time<$etime2 )) && !in_array(date("w"),[0,6]) ) {
	    	//echo "gather-{$worker->id} start   ";
	    	$gather = new Gather();
	    	$gather->run('rf_addon_tf_futures_symbol','tf_futures_trade');
			//echo "end ".(time()-$time).PHP_EOL;
//	    }
    });
};





// 如果不是在根目录启动，则运行runAll方法
if(!defined('GLOBAL_START'))
{
    Worker::runAll();
}

